package com.onegroup.controller;

import com.onegroup.pojo.IndustryType;
import com.onegroup.pojo.Project;
import com.onegroup.service.DataAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author:林秦发
 * @Description:数据分析控制层
 * @History:
 */
@RestController
@RequestMapping("/dataAnalysis")
public class DataAnalysisController {
    @Autowired
    private DataAnalysisService dataAnalysisService;

    /**
     * @description: 展示所有项目
     * @author: LinQinFa
     * @date: 2022/9/9 16:07
     * @param: [proType]
     * @return: java.util.List<com.onegroup.pojo.Project>
     **/
    @GetMapping("/showAllProjects")
    public List<Project> showAllProjects(String proType){
        List<Project> projects = dataAnalysisService.showAllProjects(proType);
        return projects;
    }

    /**
     * @description: 得到所有项目类型以及相应项目类型下的项目数量
     * @author: LinQinFa
     * @date: 2022/9/9 16:07
     * @param: []
     * @return: java.util.List<com.onegroup.pojo.Project>
     **/
    @GetMapping("/getProjectTypeAndQuantity")
    public List<IndustryType> getProjectTypeAndQuantity(){
        List<IndustryType> projectTypeAndQuantity = dataAnalysisService.getProjectTypeAndQuantity();
        return projectTypeAndQuantity;
    }


    /**
     * @description: 给当前展示的项目列表导出excel
     * @author: LinQinFa
     * @date: 2022/9/9 16:08
     * @param: [request, response]
     * @return: void
     **/
    @GetMapping("/exportExcelOfCurrentProjectList")
    public void exportExcelOfCurrentProjectList
    (HttpServletRequest request, HttpServletResponse response){
        dataAnalysisService.exportExcelOfCurrentProjectList(request,response);
    }

}
